Skip to content

Update to enable tracking id from order to trade #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

Update to enable tracking id from order to trade #199

wants to merge 3 commits into from

Conversation

qacollective
Copy link
Contributor

This is a simple change to backtesting.py to enable a user to track which trade came from which order (and a lot of other potential benefits) as outlined in issue #197.

It simply allows the assignment of an id when creating an order at with Strategy.buy() and Strategy.sell(). The id is type agnostic, so the user can make it a string, int, float or whatever may be necessary.

I could not think of a better way to solve this problem and I will be able to test that this works in the next day or so. I hope people think this is a good idea 😟 😅

This is a simple change to backtesting.py to enable a user to track which trade came from which order (and a lot of other potential benefits) as outlined in issue #197.

It simply allows the assignment of an id when creating an order at with `Strategy.buy()` and `Strategy.sell()`.  The id is type agnostic, so the user can make it a string, int, float or whatever may be necessary.

I could not think of a better way to solve this problem and I will be able to test that this works in the next day or so.  I hope people think this is a good idea 😟 😅
Copy link
Owner

@kernc kernc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will additionally need a unit test and a good example use for the docs.

Comment on lines 479 to 480
An ID attribute which, if set, persists to enable tracking of this order
if it becomes a trade in `Strategy.trades` and when closed in `Strategy.closed_trades`.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe:

An arbitrary tag object which, if set, propagates to the Trade this order started.

Which begs the question, what about orders that close existing trades?

@qacollective
Copy link
Contributor Author

Sorry, I have completely butchered the PR process here. git is driving me a bit nuts.

@kernc
Copy link
Owner

kernc commented Dec 17, 2020

Fyi, you can git push --force to overwrite existing branch contents.

@qacollective
Copy link
Contributor Author

Fyi, you can git push --force to overwrite existing branch contents.

😅 sorry, yes I'm in the difficult position of trying to do a lot with a little time at the moment, so your advice is great and something I would normally have googled to self-educate but December is 🤮 haha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants